home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 January: Mac OS SDK / Dev.CD Jan 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / langguid / chap_09 / xmpl_08.sx < prev    next >
Encoding:
Text File  |  1996-05-21  |  955 b   |  50 lines  |  [TEXT/R*ch]

  1. --<<<
  2. -- Kaleida Labs, Inc.
  3. -- Field Guide to the ScriptX Language
  4. -- chapter 9, example 8
  5.  
  6. -- set up XYZ 
  7. module XYZ
  8.     uses ScriptX
  9.     exports x, y, z
  10. end
  11. in module XYZ
  12. global x:10, y:"foo", z:#(56,567)
  13.  
  14. -- set up XYZexport, which exports its own variables (a and b),
  15. -- imports everything from XYZ, renames x to be otherX 
  16. -- and transitively exports otherX and y
  17.  
  18. module XYZexport
  19.     exports a, b
  20.     uses ScriptX
  21.     uses XYZ with 
  22.         imports everything
  23.         renames x:otherX
  24.         exports otherX, y
  25.     end
  26. end
  27. in module XYZexport
  28. global a := "croissant"
  29. global b := pi
  30. print otherX
  31. 10
  32.  
  33. -- Finally, this module uses XYZexport and imports all. The
  34. -- variables that get imported should be y (from XYZ), otherX
  35. -- (which is actually x from XYZ) and a and b (from XYZexport)
  36.  
  37. module moreXYZexport
  38.     uses ScriptX
  39.     uses XYZexport with
  40.         imports everything
  41.     end
  42. end
  43. in module moreXYZexport
  44. print a
  45. print b 
  46. print y 
  47. print otherX
  48. -- this should generate an exception
  49. print x
  50. -->>>